package com.server.server_a10.controller.garden;

import com.server.server_a10.entity.Garden.Garden;
import com.server.server_a10.entity.Inform;
import com.server.server_a10.mapper.GardenMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
public class GardenHandle {
    @Autowired
    GardenMapper gardenMapper;
    @PostMapping(value = "/getGardenInfByRoomId")
    public Inform getGardenInfByRoomId(@RequestBody Map<String,Object> request){
        int id = (int) request.get("id");
        Inform inform = new  Inform();
        List<Garden> gardens = gardenMapper.getGardenInfByRoomId(id);

        if (gardens.isEmpty()){
            inform.setCode(100);
            inform.setMsg("这个房间内应该没有\"花园\"");
        }else {
            inform.setCode(200);
            inform.setData(gardens);
            inform.setMsg("花园信息加载成功");
        }

        return inform;
    }
}
